package com.jxs.easysecurity.token;

import java.util.Calendar;

/**
 * @author jiangxingshang
 * @since 17/6/20
 */
public class AccessToken {

    protected String token;

    //明文，加密后变成token
    protected String sessionId;
    protected long timeout;
    protected String extra;

    protected AccessToken() {

    }

    public String getSessionId() {
        return sessionId;
    }

    /**
     * 凭证的有效时间，the current time as UTC milliseconds from the epoch
     * @return
     */
    public long getTimeout() {
        return timeout;
    }

    /**
     *
     * @return
     */
    public String getExtra() {
        return extra;
    }

    /**
     * 凭证是否过期。
     * @return true表示已过期。
     */
    public boolean isExpire() {
        return Calendar.getInstance().getTimeInMillis() >= timeout;
    }

    @Override
    public String toString() {
        return token;
    }
}
